Conversation
BoxiLi
left a comment
There was a problem hiding this comment.
Thanks! Could you also help us add type hints here?
|
@BoxiLi Sorry for overlooking test reproducibility! PTAL again! |
|
@mudit06mah sorry but you will have to either rebase this PR of The reason is I remember making quite some changes in bit-flip, phase-flip files because of some error etc. The testing was considerably changed due us replacing |
| (SNOT) gates followed by two CNOT gates. This creates redundancy to detect and correct | ||
| a single phase error. | ||
| The logical qubit is first encoded by two CNOT gates and then converted to the X-basis | ||
| using Hadamard (SNOT). This creates redundancy to detect and correct a single phase error. |
There was a problem hiding this comment.
| using Hadamard (SNOT). This creates redundancy to detect and correct a single phase error. | |
| using Hadamard (H). This creates redundancy to detect and correct a single phase error. |
Just did a google search for SNOT gate, it gave Did you mean: NOT gate. I don't know where the term SNOT originated from, @BoxiLi any ideas?
There was a problem hiding this comment.
Nah, historical reason. I also didn't find the source. The two original developer chosed them in 2014 I think. We should encourage the use of H
|
|
||
| It first applies the inverse of the CNOT encoding, then converts the qubits | ||
| back from the X-basis to the Z-basis using Hadamard (SNOT) gates. | ||
| It first applies the Hadamard (SNOT) gates to convert the qubits back from |
There was a problem hiding this comment.
| It first applies the Hadamard (SNOT) gates to convert the qubits back from | |
| It first applies the Hadamard (H) gates to convert the qubits back from |
tests/test_phase_flip.py
Outdated
|
|
||
| assert fidelity > 0.99, f"Fidelity too low: {fidelity:.4f}" | ||
| for _ in range(5): | ||
| seed = np.random.randint(0, 2**31 - 1) |
There was a problem hiding this comment.
This is the incorrect way of defining seed, it should ideally be fixed. Also numpy recommends using rng = np.random.default_rng(seed) from numpy 1.17
tests/test_phase_flip.py
Outdated
| fidelity = qutip.fidelity(psi, final) | ||
|
|
||
| assert fidelity > 0.99, f"Fidelity too low: {fidelity:.4f}" | ||
| for _ in range(5): |
There was a problem hiding this comment.
Use @pytest.mark.repeat(5) instead.
| qc.add_gate("SNOT", targets=[q]) | ||
|
|
||
| control = data_qubits[0] | ||
| for target in reversed(data_qubits[1:]): |
There was a problem hiding this comment.
| for target in reversed(data_qubits[1:]): | |
| for target in data_qubits[1::-1]: |
|
@Mayank447 No worries! I'll wait untill the gate refactor branch is merged. |
Description
This PR corrects the implementation of the phase flip algorithm.
Related Issue
Closes #283
Changes
SNOTgate afterCNOTinencode_circuit().SNOTgate before and after parity check for syndrome qubits.SNOTbeforeCNOTindecode_circuit().References
https://qubit.guide/13.8-correcting-phase-flips